package com.sd.robot.impl;

import com.sd.common.utils.JerseyUtil;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author fangxd
 * @project: Sdwx
 * @ClassName: RobotServiceImpl
 * @date 2020/8/21 18:17
 */
public class RobotServiceImpl {

    private static final Logger log = LoggerFactory.getLogger(RobotServiceImpl.class);

    private static final String URL = "http://62.234.92.196:8090/paasNLP/exec/ask";
    private static final String HotLoadingURL = "http://62.234.92.196:8090/paasNLP/exec/hotLoading";

    public String KnowledgeBase(String jsonStr) {
        log.info("调用URL:{} 参数：{}", URL, jsonStr);
        String result = JerseyUtil.responseJson(URL, jsonStr);
        log.info("调用知识库反馈结果:{}", result);
        return result;
    }

    public String HotLoading(String jsonStr) {
        log.info("调用URL:{} 参数：{}", HotLoadingURL, jsonStr);
        String result = JerseyUtil.responseJson(HotLoadingURL, jsonStr);
        log.info("调用热加载反馈结果:{}", result);
        return result;
    }


    public static void main(String[] args) {
        RobotServiceImpl robot = new RobotServiceImpl();
        JSONObject json = new JSONObject();
        JSONObject json1 = new JSONObject();

/*        json.put("protocolId", 1);
        json.put("robotHashCode", "sayHello");
        json.put("platformConnType", 1);
        json.put("userId", "100031");
        json.put("query", "我想去美国旅行");
        json.put("type", "text");
        json.put("entId", "HYCC");
        */

        json.put("protocolId", 1);
        json.put("robotHashCode", "address");
        json.put("platformConnType", 1);
        json.put("userId", "100031");
        json.put("query", "北京饭店");
        json.put("type", "text");
        json.put("entId", "HYCC");


//        robot.KnowledgeBase(json.toString());

        json1.put("reload_flow", "HYCC");
        robot.HotLoading(json1.toString());


    }
}
